package com.ray.controller;

import com.ray.entity.Student;
import com.ray.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/user")
public class StudentHandler {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        ModelAndView modelAndView = new ModelAndView();
        List<Student> studentList = studentService.findAll();
        modelAndView.addObject("studentList", studentList);
        modelAndView.setViewName("index");
        return modelAndView;
    }

}
